//
//  JSQMessageModel.m
//  Conversation
//
//  Created by C_HAO on 15/9/28.
//  Copyright © 2015年 CHAOO. All rights reserved.
//

#import "JSQMessageModel.h"
#import "JSQMessageTools.h"

@implementation JSQMessageModel

- (void)setText:(NSString *)text {
    _text = text;
    NSMutableAttributedString *emotion = [[NSMutableAttributedString alloc] initWithString:text attributes:[JSQMessageTools jsq_linkTextAttributes]];
    if ([JSQMessageTools analyzeEmotion:&emotion]) {
        self.attributedText = emotion;
    } else {
        self.attributedText = nil;
    }
}

- (void)setAttributedText:(NSAttributedString *)attributedText {
    if ([self.text isEqualToString:attributedText.string]) {
        _attributedText = nil;
    } else {
        _attributedText = attributedText;
    }
}

- (void)dealloc {
    _sessionID = nil;
    _messageID = nil;
    _senderId = nil;
    _senderDisplayName = nil;
    _date = nil;
    _mimeType = nil;
    _fileName = nil;
    _fileLocalPath = nil;
    _fileSize = nil;
    _mediaDuration = nil;
    _text = nil;
    _attributedText = nil;
}

@end
